package com.health.db.dao.user.impl;

import java.util.List;

import com.health.db.dao.ServiceInterface;
import com.health.db.dao.user.IStuffScheduleDao;
import com.health.db.mapper.StuffScheduleMapper;
import com.health.db.model.StuffSchedule;
import com.health.redis.RedisConstants;

public class StuffScheduleDaoImpl extends ServiceInterface implements IStuffScheduleDao {
	
	private StuffScheduleMapper stuffScheduleMapper;

	String  selectByStuffId=":stuffId:";
	public StuffScheduleMapper getStuffScheduleMapper() {
		return stuffScheduleMapper;
	}

	public void setStuffScheduleMapper(StuffScheduleMapper stuffScheduleMapper) {
		this.stuffScheduleMapper = stuffScheduleMapper;
	}

	/**
	 * stuffId 医生userId
	 */
	@Override
	public List<StuffSchedule> selectByStuff(Long stuffId) {
		// TODO Auto-generated method stub
		List<StuffSchedule> list = null;
		
		getRedisOperatiorLogic();
		
		String key =RedisConstants.StuffScheduleMapper+selectByStuffId+stuffId;
		Object object=null;
			if(redisOperatiorLogic.isJedisIsConnected())
			{	
				//get data from redis
				object = redisOperatiorLogic.readObject(key, getPublicRedisGroupNo("1"));
			 }
		     if(null!=object){
		    	 if (!object.equals("")) {
		    		 list =  (List<StuffSchedule>) object;
		    	 }
		     }else{
			
		      list =   stuffScheduleMapper.selectByStuff(stuffId);
			  if(redisOperatiorLogic.isJedisIsConnected())
				{redisOperatiorLogic.setEx(key, list,  getOrderRedisGroupNo("1"));}
			 }
		return list;
	}

}
